import { Configuration, OpenAIApi } from 'openai'

const apiKey = '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'
export class ChatGptUtils {
    private static configuration = new Configuration({
      apiKey
      });

    private static openai = new OpenAIApi(ChatGptUtils.configuration);

    public static request(msg:string){
        console.log("request msg :" + msg)
        return ChatGptUtils.openai.createCompletion({
            model: "text-davinci-003",
            prompt: msg,
            temperature: 0.9,
            max_tokens: 150,
            top_p: 1,
            frequency_penalty: 0.0,
            presence_penalty: 0.6,
            stop: [" Human:", " AI:"],
          })
    }
}
